<template>
  <!-- 热卖女装 -->
  <div class="new-product clearfix">
    <div class="new-patterns">
      <div class="tagI fl" :style="styleCss(indexFloor)"></div>
      <div class="font-title fl" v-text="indexFloor.gf_name"></div>
      <div class="font-e-title fl">{{indexFloor.en_name | toUpperCase}}</div>
      <ul class="new-pattern-nav fr">
        <li v-for="(hot, index) in indexFloor.keyWord.split(',')" 
          :key="index" 
          v-text="hot" 
          @click.stop="indexFloorJump('keyWord', hot)">
        </li>
      </ul>
    </div>
    <div class="clearfix"></div>
    <div class="hot-father" v-if="indexFloor.wide_goods">
      <div class="clearfix">
        <div class="hot-sale">
          <div class="hot-left fl" @click.stop="indexFloorJump(JSON.parse(indexFloor.wide_goods)[0].left.type, JSON.parse(indexFloor.wide_goods)[0].left.value)">
            <img v-lazy="JSON.parse(indexFloor.wide_goods)[0].left.img" class="add-img">
            <div>
              <ul>
                <li class="fl" 
                  v-for="(list, index) in (JSON.parse(indexFloor.wide_goods)[0].left.keyWord).slice(1,(JSON.parse(indexFloor.wide_goods)[0].left.keyWord).length-1).split(',')" 
                  :key="index" 
                  v-text="list" 
                  @click.stop="indexFloorJump('keyWord', list)">
                </li>
              </ul>
            </div>
          </div>
          <div class="hot-right">
            <ul>
              <li class="fl img transition-ease " 
                @click.stop="indexFloorJump(rightgood.type, rightgood.value)" 
                v-for="(rightgood, index) in (JSON.parse(indexFloor.wide_goods)[1].right.goodsList)" 
                :key="index">
                <img v-lazy="rightgood.img" class="add-img">
                <div v-text="rightgood.titleName"></div>
              </li>
            </ul>
          </div>
        </div>
      </div>
      <div class="clearfix"></div>
    </div>
  </div>
</template>

<script>
  export default {
    props: {
      indexFloor: {
        type: Object,
        default() {
          return {}
        }
      }
    },
    methods: {
      // 跳转对应页面(商品详情或者搜索页面)
      indexFloorJump(type, id, index) {
        if (index != 0 && index) {
          return
        }
        switch (type) {
          case 'goodsInfo': // 进入商品详情
            window.open('/goods/detail/' + id)
            break
          case 'channel': // 频道
            this.$emit('on-floor-channel', id)
            break
          case 'store': // 进入店铺
            this.intoStore(id)
            break
          case 'link': // 进入链接
            window.open(id.replace('/#', ''))
            break
          case 'goodsList': // 进入商品列表
            sessionStorage.setItem('goodsIds', id)
            window.open('/search/goodsLists')
            break
          case 'storeSearch':
            window.open(`/search/stores?type=stores&st=2&key=${decodeURIComponent(encodeURIComponent(id))}`)
            break
          default:
            if (type == 'brandSearch') {
              window.open(`/search/goods?type=goods&st=3&name=${decodeURIComponent(encodeURIComponent(id))}&ob=`)
            } else {
              window.open(`/search/goods?type=goods&st=1&key=${decodeURIComponent(encodeURIComponent(id))}&ob=`)
            }
        }
      },
      // 进入对应商家店铺
      intoStore(id) {
        window.open('/shop/' + id)
      }
    }
  }
</script>

<style lang="scss" scoped>
</style>